//
//  NSNumber+Convenience.m
//  golfMaster
//
//  Created by 宋鹏程 on 14-7-2.
//  Copyright (c) 2014年 Master. All rights reserved.
//

#import "NSNumber+Convenience.h"

@implementation NSNumber (Convenience)

+ (instancetype)numberWithObject:(NSObject *)objc
{
    if(objc.isNull || !objc) return [NSNumber numberWithInteger:0];
    return (NSNumber *)objc;
}

+ (BOOL)boolWithObject:(NSObject *)objc
{
    if(objc.isNull || !objc) return NO;
    return [(NSNumber *)objc boolValue];
}

+ (NSInteger)integerWithObject:(NSObject *)objc holdInteger:(NSInteger)integer
{
    if (objc.isNull || !objc) return integer;
    return [(NSNumber *)objc integerValue];
}

+ (NSUInteger)uIntegerWithObject:(NSObject *)objc holdUInteger:(NSUInteger)uInteger
{
    if (objc.isNull || !objc) return uInteger;
    return [(NSNumber *)objc unsignedIntegerValue];
}

+ (CGFloat)floatWithObject:(NSObject *)objc holdFloat:(NSUInteger)hFloat
{
    if (objc.isNull || !objc) return hFloat;
    return [(NSNumber *)objc floatValue];
}

@end
